package main

import (
	"io/ioutil"
	"net/http"
	"os"
)

func main() {
	http.HandleFunc("/list/", fileList)

	http.ListenAndServe(":8080", nil)
}

func fileList(writer http.ResponseWriter, request *http.Request) {
	reqPath := request.URL.Path[len("/list/"):]
	file, err := os.Open(reqPath)
	if err != nil {
		panic(err)
	}
	defer file.Close()

	content, err := ioutil.ReadAll(file)
	if err != nil {
		panic(err)
	}

	writer.Write(content)

}
